package cn.mingfancloud.基础知识.字符串;

public class CodePointCountDemo {

    public static void main(String[] args) {
        // 创建一个代表“好”字符的字符串数组，
        char[] aCharArray = { '\u597d' };
        String a = new String(aCharArray);
        System.out.println("a = " + a);
        // 输出字符串代码单元数量
        System.out.println("a.length = " + a.length());
        // 输出字符串代码点数量
        System.out.println("a.codePointCount = " + a.codePointCount(0, a.length()));
        // 创建代表一个增补字符的字符串数组，
        char[] bCharArray = { '\uD875', '\uDD6B' };
        String b = new String(bCharArray);
        System.out.println("b = " + b);
        // 输出字符串代码单元数量
        System.out.println("b.length = " + b.length());
        // 输出字符串代码点数量
        System.out.println("b.codePointCount = " + b.codePointCount(0, b.length()));
    }

}



